﻿@model List<iChip.Hotspots.Models.Splash>
@{
    ViewBag.Title = "Danh sách Splash";
    Layout = "~/Views/Shared/_LayoutAdmin.cshtml";
}
<!-- BEGIN SAMPLE PORTLET CONFIGURATION MODAL FORM-->
<div id="modalMethod" class="modal fade" tabindex="-1" data-width="400">
    <div class="modal-dialog">
        <div class="modal-content">
           
        </div>
    </div>
</div>
<!-- /.modal -->
<!-- END SAMPLE PORTLET CONFIGURATION MODAL FORM-->
<!-- BEGIN PAGE HEADER-->
<div class="row">
    <div class="col-md-12">
        <!-- BEGIN PAGE TITLE & BREADCRUMB-->
        <h3 class="page-title">
            Danh sách Splash
        </h3>
        <ul class="page-breadcrumb breadcrumb">
            <li>
                <i class="icon-home"></i>
                <a href="/">Home</a>
                <i class="icon-angle-right"></i>
            </li>
            <li><a href="#">Danh sách Splash</a></li>
            <li class="pull-right">
            </li>
        </ul>
        <!-- END PAGE TITLE & BREADCRUMB-->
    </div>
</div>
<!-- END PAGE HEADER-->
<div class="row">
    <div class="col-md-12 col-sm-12">
        <!-- BEGIN EXAMPLE TABLE PORTLET-->
        <div class="portlet box grey">
            <div class="portlet-title">
                <div class="caption"><i class="icon-globe"></i>Danh sách Splash</div>
                <div class="actions">
                    <a href="@Url.Action("AddSplash", "Admin", new  { Hotspot_id = @ViewBag.Hotspot_id, Hotspot_mac = @ViewBag.Hotspot_Mac, returnUrl=@Request.RawUrl})" class="btn blue"><i class="icon-pencil"></i> Thêm mới Splash</a>                    
                </div>
            </div>
            <div class="portlet-body">
                @if(Model!=null && Model.Count>0)
                { 
                <table class="table table-striped table-bordered table-hover" id="tbHotspots">
                    <thead>
                        <tr>
                            <th>Tên Splash</th>                            
                            <th>Hotspot Mac</th>
                            <th>User Type</th>
                            <th>Start Time</th>
                            <th>End Time</th>
                            <th>Splash UrlRedirect</th>
                            <th>Tùy chọn</th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach(var item in Model)
                        { 
                            <tr class="odd gradeX">
                                <td>@item.Splash_Name</td>
                                <td>@item.Hotspot_Mac</td>
                                <td>
                                    @if (item.User_Type == 1) // VIP
                                    {
                                        <span class="label label-sm label-success">VIP</span>
                                    }
                                    else
                                    {
                                        <span class="label label-sm label-warning">NOR</span>
                                    }
                                </td>
                                <td>@Convert.ToDateTime(item.Splash_StartTime).ToString("dd/MM/yyyy HH:mm")</td>
                                <td>@Convert.ToDateTime(item.Splash_EndTime).ToString("dd/MM/yyyy HH:mm")</td>                             
                                <td>@item.Splash_UrlRedirect</td>                                                                
                                <td>
                                    <a name="aEdit" href="@Url.Action("AddSplash", "Admin", new { splash_id = @item.Splash_Id, Hotspot_id = @ViewBag.Hotspot_id, Hotspot_mac = @ViewBag.Hotspot_Mac, returnUrl = @Request.RawUrl })" data-id="@item.Splash_Id" class="btn default btn-xs purple"><i class="icon-edit"></i> Sửa</a>&nbsp;
                                    <a href="#" class="btn default btn-xs blue" data-splashid="@item.Splash_Id" onclick="showModal(this)"><i class="icon-share"></i> Method</a>&nbsp;
                                    <a href="#" class="btn default btn-xs black"><i class="icon-trash"></i> Xóa</a>&nbsp;
                                </td>
                            </tr>
                        }                        
                    </tbody>
                </table>
                }
            </div>
        </div>
        <!-- END EXAMPLE TABLE PORTLET-->
    </div>    
</div>

@section Scripts {
    <script>
        function showModal(el) {
            console.log($(el), $(el).data("splashid"));
            $.ajax({
                cache: false,
                type: 'POST',
                url: '@Url.Action("ListMethods", "AdminMethods")',
                data: {
                    splash_id: $(el).data("splashid"),
                    returnUrl: '@Request.RawUrl'
                },
                success: function (data) {
                    $("#modalMethod").find(".modal-content").html(data);
                    $('#modalMethod').modal('show');
                }
            });
            
        }
    </script>
    
}